﻿namespace MediatorPattern.DemoTwo
{
    /// <summary>
    /// 庫存管理類
    /// </summary>
    public class Stock : AbstractColleague
    {
        public Stock(AbstractMediator _mediator) : base(_mediator)
        {
        }

        private static int COMPUTER_NUMBER = 100;

        /// <summary>
        /// 庫存增加
        /// </summary>
        /// <param name="number"></param>
        public void increase(int number)
        {
            COMPUTER_NUMBER = COMPUTER_NUMBER + number;
        }

        /// <summary>
        /// 庫存減少
        /// </summary>
        /// <param name="number"></param>
        public void decrease(int number)
        {
            COMPUTER_NUMBER = COMPUTER_NUMBER - number;
        }

        /// <summary>
        /// 獲取庫存量
        /// </summary>
        /// <returns></returns>
        public int getStockNumber()
        {
            return COMPUTER_NUMBER;
        }

        /// <summary>
        /// 儘快銷售
        /// </summary>
        public void clearStock()
        {
            mediator.execute("stock.clear");
        }
    }
}